package com.store.practice.service.impl;

import com.store.practice.dao.MemberMapper;
import com.store.practice.mapper.BgAppointmentOrderMapper;
import com.store.practice.model.BgAppointmentOrder;
import com.store.practice.model.BgAppointmentOrderExample;
import com.store.practice.model.BgMember;
import com.store.practice.service.MemberManageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MemberManageServiceImpl implements MemberManageService {
    @Autowired
    private MemberMapper memberMapper;
    @Autowired
    private BgAppointmentOrderMapper orderMapper;

    @Override
    public List<BgMember> list(Integer storeId) {
        return memberMapper.getMemberByStoreId(storeId);
    }

    @Override
    public List<BgAppointmentOrder> getOrder(Integer mbrId) {
        BgAppointmentOrderExample example = new BgAppointmentOrderExample();
        example.createCriteria().andMbrIdEqualTo(mbrId);
        List<BgAppointmentOrder> list = orderMapper.selectByExample(example);
        if (list==null){
            return null;
        }
        return list;
    }

    @Override
    public int updateStatus(Integer id, Integer status) {
        BgAppointmentOrder order = orderMapper.selectByPrimaryKey(id);
        if (status==0){
            order.setStatus(0);
        }
        if (status==1){
            order.setStatus(2);
        }
        return orderMapper.updateByPrimaryKey(order);
    }
}
